package com.lan.enums.sys;

import lombok.Getter;

import java.util.stream.Stream;

@Getter
public enum MenuTypeEnum {

    FOLDER("目录",0),
    MENU("菜单", 1),
    BUTTON("按钮", 2);

    /**
     * 编码.
     **/
    private final Integer value;
    /**
     * 中文名称.
     **/
    private final String name;

    MenuTypeEnum(final String name, final Integer value) {
        this.name = name;
        this.value = value;
    }

    public static String getNameByValue(final Integer value) {
        return Stream.of(MenuTypeEnum.values())
                .filter(x -> x.getValue() == value.intValue())
                .findFirst()
                .map(MenuTypeEnum::getName)
                .orElse(null);
    }
}
